package hqu.cst.xah.onlinemaill.mapper;

import hqu.cst.xah.onlinemaill.pojo.Order;
import hqu.cst.xah.onlinemaill.pojo.Product;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Select("select * from `order`")
    List<Order> getAllOrders(Object o);

    // 删除订单
    @Delete("DELETE FROM `order` WHERE id = #{orderId}")
    int deleteOrder(Integer orderId);

    // 更新订单
    @Update("UPDATE `order` SET productName = #{productName}, price = #{price}, quantity = #{quantity}, orderDate = #{orderDate} WHERE id = #{id}")
    int updateOrder(Order updatedOrder);

    @Insert("INSERT INTO `order` (productId, productName, price, quantity, orderDate) VALUES (#{productId}, #{productName}, #{price}, #{quantity}, #{orderDate})")
    int insertOrder(Order order);
}
